< previous page page_457 next page >

Page 457
e10a6a0a59f035e870d90cca05b85fce.gif
' Create a 3-D transformation matrix for a
' projection with:
'       center of projection      (cx, cy, cz)
'       focus                     (fx, fy, fx)
'       UP vector                 <ux, yx, uz>
' ptype should be m3Perspective or m3Parallel.
Public Sub m3Project(M() As Single, ByVal ptype As Integer, _
    ByVal cx As Single, ByVal cy As Single, _
    ByVal cz As Single, ByVal Fx As Single, _
    ByVal Fy As Single, ByVal Fz As Single, _
    ByVal ux As Single, ByVal uy As Single, _
    ByVal uz As Single) 
Static M1(1 To 4, 1 To 4) As Single
Static M2(1 To 4, 1 To 4) As Single
Static M3(1 To 4, 1 To 4) As Single
Static M4(1 To 4, 1 To 4) As Single
Static M5(1 To 4, 1 To 4) As Single
Static M12(1 To 4, 1 To 4) As Single
Static M34(1 To 4, 1 To 4) As Single
Static M1234(1 To 4, 1 To 4) As Single
Dim sin1 As Single
Dim cos1 As Single
Dim sin2 As Single
Dim cos2 As Single
Dim sin3 As Single
Dim cos3 As Single
Dim A As Single
Dim B As Single
Dim C As Single
Dim d1 As Single
Dim d2 As Single
Dim d3 As Single
Dim up1(1 To 4) As Single
Dim up2(1 To 4) As Single

    ' Translate the focus to the origin.
    m3Translate M1, -Fx, -Fy, -Fz

    A = cx - Fx
    B = cy - Fy
    C = cz - Fz
    d1 = Sqr(A * A + C * C)
    If d1 <> 0 Then
        sin1 = -A / d1
        cos1 = C/ d1
    End If
    d2 = Sqr(A * A + B * B + C * C)
    If d2 <> 0 Then
        sin2 = B / d2
        cos2 = d1 / d2
    End If

 
< previous page page_457 next page >